<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // window.addEventListener('load', function () {
        //     const but = document.querySelector('button');
        //     but.addEventListener('click', function () {
        //         alert('1111111');
        //     })
        // })
        document.addEventListener('DOMContentLoaded', function () {
            const but1 = document.querySelector('button');
            console.log(but1);
            but1.addEventListener('click', function () {
                alert('pppp');
            })
        })
    </script>
</head>

<body>
    <button>qqqqqq</button>
    <p>wwwwwww</p>
</body>

</html>